﻿using System;
using Dos.ORM;
using Finance.Poco;

namespace ConsoleApplication1
{
    internal class Program
    {
        private static void Main(string[] args)
        {
            var dbSession = new DbSession("finance");
            dbSession.RegisterSqlLogger(Console.WriteLine);
            //dbSession.Insert(new User()
            //    {
            //        UserName = "admin",
            //        Password = "123456",
            //        CreateTime = DateTime.Now,
            //        CreateUserName = "admin",
            //        Is_enable = "true"
            //    });
            int userCount = dbSession.Count<User>(user => user.Id > 0);
            var firstUser =
                dbSession.From<User>()
                         .Where(user => user.LastLoginTime < DateTime.Now)
                         .Distinct()
                         .OrderBy(user => user.UserName)
                         .Page(20, 1)
                         .ToList();
            // firstUser.LastLoginTime = DateTime.Now;
            // firstUser.Attach(EntityState.Modified);
            //dbSession.Save(firstUser);
            Console.Read();
        }
    }
}